<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
	<%@include file="/WEB-INF/common/taglibs.jsp"%>    
    <title>江苏龙芯梦兰科技股份有限公司-SMT生产管理系统</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="${ctx}resources/css/common.css" />
  </head>
  <script type="text/javascript">
  
 	$(function(){
 		$("#birthday").datepick({dateFormat: 'yy-mm-dd'});
 	});
  		function submitForm(){
  		var wc = $("#workCard").val();
  		var userid = $("#userid").val();
  		var realName = $("#realName").val();
  		var password = $("#password").val();
  		var repassword = $("#repassword").val();
  		if(realName==""){
  			alert("用户姓名不能为空!");
  			$("#realName").focus();
  			return ;
  		}
  		if(password==""){
  			alert("用户密码不能为空!");
  			$("#realName").focus();
  			return ;
  		}
  		if(password.length<5){
  			alert("用户密码不能少于6个字符!");
  			$("#password").focus();
  			return ;
  		}
  		if(repassword==""){
  			alert("用户确认密码不能为空!");
  			$("#repassword").focus();
  			return ;
  		}
  		if(repassword!=password){
  			alert("用户密码与确认密码不一致!");
  			$("#repassword").focus();
  			return ;
  		}
  		if(""==wc){
  			alert("工卡号不能为空!");
  			$("#workCard").focus();
  			return ;
  		}
  		  if(userid==null){
	  		  $.ajax({ 
			      url: "${ctx}user/verify.htm", 
			      type: "POST", 
			      data: ({"wc":wc,"id":userid}), 
			      dataType: "json", 
			      async:false, 
			      success: function(data){ 
			         if(data.msg=="Y"){
			        	 alert("工卡号已存在！");
			        	 $("#userid").focus();
				         return ;
			         }
			         $("#saveUser").submit();
			      }
			   });
  		  }else{
  			   $("#saveUser").submit();
  		  }
  	}
  	
  </script>
 <body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="24" bgcolor="#353c44"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="6%" height="19" valign="bottom"><div align="center"><img src="${ctx}resources/images/tb.gif" width="14" height="14" /></div></td>
                <td width="94%" valign="bottom"><span class="STYLE1">${model==null? "添加":"修改 "}${model==null?"":model.realName} 用户</span></td>
              </tr>
            </table></td>
            <td></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>
    <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#d3eaef">
      <tr>
        <td width="100%" height="auto" bgcolor="#d3eaef">
        	<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#d3eaef">
              <tr>
                <td width="100%" height="20" align="left" style="text-indent:20px;font-size: 12px">带*号为必填选项</td>
              </tr>
   			</table>
        </td>
      </tr>
   	<form action="${ctx}user/saveUser.htm" method="post" id="saveUser">
 		<input type="hidden" name="user.id" id="userid" value="${model.id}">
     <tr>
        <td width="100%" height="20" bgcolor="#d3eaef">
	        	<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#fbfcfd">
	              <tr height="25">
	                <td width="42%"  align="right">*姓名: </td>
	                <td width="15%" align="left"><input type="text" style="width:100%" name="user.realName" id="realName" value="${model.realName}"/></td>
	                <td width="43%" align="left" class="slyle_text"></td>
	              </tr>
	              </table>
	     </td>
	  </tr>
	  <tr>
	  		<td>
	              <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#fbfcfd">
	              <tr height="25">
	                <td width="42%"  align="right">*工卡号: </td>
	                <td width="15%" align="left"><input type="text" style="width:100%" name="user.workCard" id="workCard" value="${model.workCard}" ${model.id==null?"":"readonly"}/></td>
	                <td width="43%" align="left" class="slyle_text"> ${model.id==null?"<font color='red'>* 添加之后不可修改</font>":"<font color='red'>* 此项目不可修改</font>"}</td>
	              </tr>
	              </table>
	     </td>
	  </tr>
	  <tr>
	  	<td>
	   			  <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#fbfcfd">
	              <tr height="25">
	                <td width="42%" align="right">*密码: </td>
	                <td width="15%" align="left"><input type="password" name="user.password" id="password" style="width:100%"/></td>
	                <td width="43%" align="left" class="slyle_text"></td>
	              </tr>
	             </table>
	     </td>
	  </tr>
	  <tr>
		<td>
		 <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#fbfcfd">
	              <tr height="25">
	                <td width="42%" align="right">*确认密码: </td>
	                <td width="15%" align="left"><input type="password" style="width:100%" id="repassword" name="repassword"/></td>
	                <td width="43%" align="left" class="slyle_text"></td>
	              </tr>
	       </table>
	      </td>
	   </tr>
	   <tr>
	   <td>
	    <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#fbfcfd">
	              <tr height="25">
	                <td width="42%" align="right">性别:</td>
	                <td width="15%" align="left" >&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="user.sex" ${model.sex==null?"checked": model.sex ==0?"checked":""}  value="0"/>男<input type="radio" name="user.sex" ${model.sex==1?"checked":""} value="1"/>女</td>
	                <td width="43%" align="left" class="slyle_text"></td>
	              </tr>
	        </table>
	     </td>
	  </tr>
	   <tr>
	   <td>
	    <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#fbfcfd">
	              <tr height="25">
	                <td width="42%" align="right">状态:</td>
	                <td width="15%" align="left" >&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="user.status" ${model.status==null?"checked": model.status ==0?"checked":""}  value="0"/>正常<input type="radio" name="user.status" ${model.status==1?"checked":""} value="1"/>限制</td>
	                <td width="43%" align="left" class="slyle_text"></td>
	              </tr>
	        </table>
	     </td>
	  </tr>
	  <tr>
	  	<td>
	  		<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#fbfcfd">
	              <tr height="25">
	                <td width="42%" align="right">电话: </td>
	                <td width="15%" align="left"><input type="text" style="width:100%" name="user.phone" value="${model.phone}"/></td>
	                <td width="43%" align="left" class="slyle_text"></td>
	              </tr>
	           </table>
	      </td>
	  </tr>
	  <tr>
	  	<td>
	  		<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#fbfcfd">
	              <tr height="25">
	                <td width="42%" align="right">地址: </td>
	                <td width="15%" align="left"><input type="text" style="width:100%" name="user.addr" value="${model.addr}"/></td>
	                <td width="43%" align="left" class="slyle_text"></td>
	              </tr>
	         </table>
	     </td>
	 </tr>
	 <tr>
	 	<td>
	 		<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#fbfcfd">
	              <tr height="25">
	                <td width="42%" align="right">生日: </td>
	                <td width="15%" align="left"><input type="text" style="width:100%" id="birthday" readonly="readonly" name="user.birthday" value="<fmt:formatDate value='${model.birthday}' pattern='yyyy-MM-dd' />"/></td>
	                <td width="43%" align="left" class="slyle_text"></td>
	              </tr>
	   			</table>
	   	</td>
	 </tr>
	 <tr>
	 	<td>
	            <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#fbfcfd">
	              <tr height="25">
	                <td width="42%" align="right">用户组: </td>
	                <td width="35%"></td>
	                <td width="23%" class="slyle_text"></td>
	              </tr>
	               <tr height="25">
	                <td width="42%" align="right"></td>
	                <td width="35%" style="line-height:20px">
	                	<span><s:checkboxlist name="checkedGroupIds" list="allGroupList" listKey="id" listValue="groupName" theme="custom"/></span>
	                </td>
	                <td width="23%" class="slyle_text"></td>
	              </tr>
	   			</table>
	   			</form>
	   		</td>
	   	</tr>
	   	<tr>
	   		<td>
            <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ffffff">
              <tr height="50" >
                <td width="50%" align="right"><input type="image" onclick="submitForm()" src="${ctx}resources/images/dl_1.gif" /></td>
                <td width="50%" style="text-indent:5px"><a href="${ctx}user/list.htm"><img src="${ctx}resources/images/dl_2.gif" style="border: 0px"/></a></td>
              </tr>
   			</table>
        </td>
      </tr>
    </table>
    </td>
  </tr>
</table>
</body>
</html>
